import numpy as np
import matplotlib.pyplot as p

class AppPlot():

	def plotImg(self, strTitlePplot):

		self.strTitlePplot = strTitlePplot
		fig = p.figure()
		ax = fig.add_subplot(1,1,1)
		 
		# note the change: I'm only supplying y data.
		y = [4, 6, 7, 3, 5]
		 
		# Calculate how many bars there will be
		N = len(y)
		 
		# Generate a list of numbers, from 0 to N
		# This will serve as the (arbitrary) x-axis, which
		# we will then re-label manually.
		ind = range(N)
		 
		# I'm also supplying (fake) error for each y value.
		# You can use numpy's standard deviation, numpy.std(data)
		# to calculate error bars for your own data.
		# Standard error is standard deviation over sqrt(N),
		# so you could use numpy.std(x)/numpy.sqrt(len(x))
		# to get standard error for the data in a list x.
		err = [1.2, 1.5, 2.5, 1.2, 2.0]
		 
		# See note below on the breakdown of this command
		ax.bar(ind, y, facecolor='#777777', align='center', yerr=err, ecolor='black')
		 
		#Create a y label
		ax.set_ylabel('Counts')
		 
		# Create a title, in italics
		ax.set_title(self.strTitlePplot, fontstyle='italic')
		 
		# This sets the ticks on the x axis to be exactly where we put
		# the center of the bars.
		ax.set_xticks(ind)
		 
		# Labels for the ticks on the x axis.  It needs to be the same length
		# as y (one label for each bar)
		group_labels = ['control', 'cold treatment',
		                 'hot treatment', 'another treatment',
		                 'the last one']
		 
		# Set the x tick labels to the group_labels defined above.
		ax.set_xticklabels(group_labels)
		 
		# Extremely nice function to auto-rotate the x axis labels.
		# It was made for dates (hence the name) but it works
		# for any long x tick labels
		fig.autofmt_xdate()
		 
		p.show()